#!/bin/bash
currentShellDir=$(cd $(dirname $0); pwd)
installDocker() {
    sudo apt-get remove docker docker-engine docker.io containerd runc
    sudo apt-get update
    sudo apt-get -y install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    # curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    #sudo apt-key fingerprint 0EBFCD88
    sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
    sudo apt-get update
    sudo apt-get -y install docker-ce docker-ce-cli containerd.io

    sudo mkdir -p /etc/docker
    sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://hzo2olxj.mirror.aliyuncs.com","http://hub-mirror.c.163.com","https://registry.docker-cn.com"]
}
EOF
    sudo wget -P /usr/local/bin http://soft.qiniu.anzhongwei.cn/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    sudo systemctl enable docker
    #sudo docker run hello-world
    /bin/echo -e "docker版本信息：\n"
    sudo docker version
    /bin/echo -e "docker-compose版本信息：\n"
    sudo docker-compose version
    sudo cp ${currentShellDir}/docker-tags /usr/local/bin
    sudo chmod +x /usr/local/bin/docker-tags
}

installDocker